Skip to content

Conversation

@matho-odoo
Copy link

@matho-odoo matho-odoo commented Nov 26, 2025

Description:

Add some shortcuts

Task: 5231802

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Nov 26, 2025

Pull request status dashboard

@matho-odoo matho-odoo changed the base branch from 19.0 to master November 26, 2025 14:27
@matho-odoo matho-odoo force-pushed the master-add-shortcuts-matho branch 6 times, most recently from 0130936 to 945f5c2 Compare December 2, 2025 11:51
old tests did not actually test the shortcuts functionality
there was nothing asserted

Task : 5231802
shift+F11 (new sheet), ctrl+enter (fill range) and alt+t (new table)

Task: 5231802
@matho-odoo matho-odoo force-pushed the master-add-shortcuts-matho branch from 945f5c2 to ba72476 Compare December 2, 2025 15:22
Copy link
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello 👋

Reading the spec of the task, you didn't do Insert row/column, was that discussed with francois ? And Insert Comment, but that's odoo specific.

Also the spec mentions showing the shortcuts in Odoo's ctrl+k menu, but I'm for doing it in another task.

bottom: multipleRowsInSelection ? zone.top : zone.top - 1,
top: multipleRowsInSelection ? zone.top : zone.top - 1,
};
this.originSheetId = this.getters.getActiveSheetId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowDispatch should not change the state of the plugin. and this.originSheetId is not used here anyway

same comment for copy on left/copy on zone

Comment on lines +2027 to +2028
const { INSERT_TABLE } = require("../../src/actions/menu_items_actions");
expect(INSERT_TABLE as jest.Mock).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove this (and the jest.mock("../../src/actions/menu_items_actions.ts" at top of the file), you already tested that a table was inserted.

In general avoid mocking imports unless absolutely necessary. It makes tests harder to understand, and breaks if we ever move files around.

Testing what the result of an action is is the superior option over testing expect(helper).toHaveBeenCalled() anyway. Testing that the helper has been called doesn't actually test much, the helper could be broken and not do anything, and the test wouldn't notice. Just test that a table was inserted, and it's enough 🙂

});

test("can copy and paste cell(s) on left using CTRL+R", async () => {
test("banane", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍌 🍌 🍌

Comment on lines +1990 to +1991
// @ts-ignore
const notificationStore = env.__spreadsheet_stores__.get(NotificationStore);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid ts-ignore when possible. I'm guessing env.getStore(NotificationStore) doesn't work because of the proxy ? Otherwise you could create a mock raiseError function and give it to the env (see raiseError tests in bottom_bar_component.test.ts)

Comment on lines 99 to 102
expect(
fixture.querySelector(".o-menu .o-menu-item[data-name='insert_link']")?.textContent
fixture.querySelector(".o-menu .o-menu-item[data-name='insert_link'] .o-menu-item-name")
?.textContent
).toBe("Insert link");
Copy link
Contributor

@hokolomopo hokolomopo Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: expect(".o-menu .o-menu-item[data-name='insert_link'] .o-menu-item-name").toHaveText("Insert link")

see our custom jest matchers in jest_extend.ts

notificationStore.updateNotificationCallbacks({
notifyUser: mockEnv.notifyUser || (() => {}),
raiseError: mockEnv.raiseError || (() => {}),
raiseError: mockEnv.raiseError || (jest.fn() as unknown as (message: string) => void),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As i said in a previous comment, pass a mocked raiseError to the env instead (mockEnv.raiseError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants